#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <fcntl.h>
#include <unistd.h>

const char *filename = "log.txt";

int main()
{
  struct stat st;
  int n = stat(filename, &st);
  if(n < 0) return 1;
  printf("file size:%lu\n", st.st_size);
  //int fd = open(filename, O_CREAT | O_WRONLY | O_TRUNC, 0666);
  int fd = open(filename, O_RDONLY);
  if(fd < 0)
  {
    perror("open");
    return 2;
  }
  printf("fd : %d\n", fd);
  
  char *file_buffer = (char*)malloc(st.st_size + 1);

  

  /*const char *message = "hello Linux\n";
  write(fd, message, strlen(message));
  close (fd);*/
  return 0;
}
